import SceneController, { TButton, TScene } from "./SceneControl";

export default abstract class Scene extends cc.Component {

    tscene: TScene = null;

    public abstract initScene();

    protected onEnable(): void {
        this.tscene = new TScene(this.node.name);
    }

    public pauseService() {
        SceneController.getInstance().inService = false;
    }

    public resumeService() {
        SceneController.getInstance().inService = true;
    }

    protected onDisable(): void {
        this.tscene.removeThis();
        this.tscene = null;
    }

    public getBtn(path: string, offset?: cc.Vec3, parent: cc.Node = this.node) {
        let node = cc.find(path, parent);
        if (node) {
            let btn = new TButton(node);
            if (offset) btn.offset = offset;
            return btn;
        } else {
            cc.error("未找到——" + path);
        }
    }

}
